<!DOCTYPE html>
<html>
<head>
    <title>家校通</title>
    <meta name="keywords" content=""/>
    <meta name="description" content="">
    <include file="public@head"/>
</head>

<body class="body-white" id="top">
<include file="public@nav" />
<div class="container tc-main">
    <div class="row">
        <div class="col-md-3">
            <include file="public@jiaxiaonav"/>
        </div>
        <div class="col-md-9">

            <!--标题 -->
            <div class="personal-nav" style="padding-bottom: 50px;">
                <h2>请假申请</h2>
            </div>
            <!--标题 -->

            <form class="form-horizontal js-ajax-form" action="{:url('student/FrontStudent/addPost')}" method="post">
                <input type="hidden" name="student_id" value="{$student_id}"/>

                <div class="form-group">
                    <label for="class_id" class="col-sm-2 control-label">班级</label>
                    <div class="col-sm-10">
                        <select class="personal-student-select" name="class_id" id="class_id">
                            <option value='0'>--- 请选择 ---</option>
                            <notempty name="classes">
                                <foreach name="classes" item="vo">
                                    <if condition="isset($param.class_id) && $param.class_id eq $vo.id">
                                        <option value="{$vo.id}" selected>{$vo.name}</option>
                                    <else/>
                                        <option value="{$vo.id}">{$vo.name}</option>
                                    </if>
                                </foreach>
                            </notempty>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="course_time" class="col-sm-2 control-label">请假课时</label>
                    <div class="col-sm-10">
                        <select class="personal-student-select" name="course_time" id="course_time">
                            <option value='0'>--- 请选择 ---</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="reason" class="col-sm-2 control-label">请假原因</label>
                    <div class="col-sm-10">
                        <textarea class="personal-student-select" style="height: auto;" rows="5" name="reason" id="reason"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="change_course" class="col-sm-2 control-label">补课方式</label>
                    <div class="col-sm-10">
                        <select class="personal-student-select" name="change_course" id="change_course">
                            <option value='0'>不申请</option>
                            <option value='1'>申请录音</option>
                            <option value='2'>申请调课</option>
                        </select>
                        <span class="col-sm-10" style="color: red; font-style: italic;">
                            <i class="glyphicon glyphicon-info-sign"></i> 补课最多可以申请3次
                        </span>
                    </div>
                </div>

                <div class="form-group">
                    <div class="text-center">
                        <button type="submit" class="btncss  js-ajax-submit">提交</button>
                    </div>
                </div>
            </form>
            <div>
            </div>

        </div>
    </div>
</div>

<include file="public@footer" />

<include file="public@scripts" />

<script type="text/javascript">
    $(document).ready(function () {
        $('#class_id').on('change',function () {
            var cid = $(this).val();
            if(cid == 0){
                $('#course_time').empty();
                var html = '<option value=\"0\">--- 请选择 ---</option>';
                $('#course_time').html(html);
                return false;
            }
            $.ajax({
                url:"{:url('student/FrontStudent/ajax_schedule')}",
                type:'post',
                dataType:'json',
                data:{"class_id":cid},
                success:function(jsonData){
                    $('#course_time').empty();
                    var html = '<option value=\"0\">--- 请选择 ---</option>';

                    if(jsonData.code == 1){
                        var schedule = jsonData.data;
                        for(var i in schedule){
                            //html += '<option value=\"'+schedule[i].date+','+schedule[i].start_time+','+schedule[i].end_time+','+schedule[i].week+','+schedule[i].schedule+'\">'+
                            html += '<option value=\"'+schedule[i].schedule+'\">'+
                                schedule[i].date_time+' '+schedule[i].start_time+'-'+schedule[i].end_time+' '+schedule[i].week+' '+schedule[i].schedule+'</option>';
                        }
                    }
                    $('#course_time').html(html);
                },
                error:function(XMLHttpRequest, textStatus, errorThrown){
                    console.log('xhr='+XMLHttpRequest.readyState+' status='+textStatus+' error='+errorThrown);
                }
            });
        });
    });
</script>
</body>
</html>